/**
 * @author Evgeny Sorokin
 */
Ext.define('USocial.view.Login', {
    extend: 'Ext.Panel',
    xtype: 'login',
    config: {
		fullscreen : true,
        items: [
	        {
	        	xtype : 'button',
	        	text : 'Login via Vkontakte',
	        	centered : true,
	        	handler : function(){
			         var ref = window.open('https://oauth.vk.com/authorize?client_id=4181551&scope=friends,wall,offline&redirect_uri=https://oauth.vk.com/blank.html&display=touch&v=5.10&response_type=token&scope=offline', '_blank', 'location=no');
			         ref.addEventListener('loadstop', function(event) { 
			         	var userId,
			         		accessToken;
			         	
			         	//parseUrl, then...
			         	/*USocial.setUserId(userId);
			         	Ext.create('USocial.model.UserInfo',{
			         		uid : userId,
			         		token : accessToken
			         	}, userId).save();*/
			         		
			         	//Store token and other device data to localstorage 
			         	Ext.device.Notification.show({
			         		title : 'Custom title',
			         		message : event.url,
			         		buttons: Ext.MessageBox.OK
			         	}); 
			         });
	        	}
	        }
        ]
    }
});
